package com.xiaobaibai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaobaibai.dao.UserIntegralDetailDao;
import com.xiaobaibai.entity.UserIntegralDetail;
import com.xiaobaibai.service.IUserIntegralDetailService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaobaibai
 * @since 2020-10-16
 */
@Service
public class UserIntegralDetailServiceImpl extends ServiceImpl<UserIntegralDetailDao, UserIntegralDetail> implements IUserIntegralDetailService {

    @Override
    @Cacheable(value = "integral",key = "#root.methodName+'-'+#userId")
    public List<UserIntegralDetail> getUserIntegralDetailByUserId(Integer userId) {
        QueryWrapper<UserIntegralDetail> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        queryWrapper.orderByDesc("create_time");
        return this.list(queryWrapper);
    }

}
